package com.detect.main;

import java.util.List;

import com.detect.exception.FileDoesNotExistException;
import com.detect.model.FileInfo;
import com.detect.service.ScanService;
import com.detect.service.ScanServiceImpl;

public class Main {

    private static String[] paths = { "D:\\360安全浏览器下载\\APKOpitimize" };

    /**
     * @param args
     */
    public static void main(String[] args) {
        long startTime = System.currentTimeMillis(); // 获取开始时间

        ScanService sService = new ScanServiceImpl(paths, true, 10 * 1024,
                512 * 1024 * 1024, 2);
        try {
            sService.doScan();
        } catch (FileDoesNotExistException e) {
            System.out.println("File " + e.getFilePath() + " does not exsit!");
        }

        long endTime = System.currentTimeMillis(); // 获取结束时间
        System.out.println("总用时: " + (endTime - startTime) + " ms");
        System.out.println("共扫描: " + sService.getFileCount() + " 个文件");

        long totalSize = 0;
        List<FileInfo> files = sService.getFileInfos();
        for (FileInfo file: files) {
            totalSize += file.getFileSize();
        }

        System.out
                .println("总大小: "
                        + (totalSize > 1024 * 1024 * 1024 ? totalSize / 1024.0 / 1024.0 / 1024.0
                                : totalSize / 1024.0 / 1024.0)
                        + (totalSize > 1024 * 1024 * 1024 ? " GB" : " MB"));
    }
}
